package helper

import (
	"Hypnos-Soundcore/constants"
)

// BuildStatusResponseByLanguage .
func BuildStatusResponseByLanguage(status, code int, message, lang string) interface{} {
	return StatusResponse{Status: status, Response: BuildResponseByLanguageV2(code, message, lang)}
}

// BuildResponseByLanguageV1 build response v1
func BuildResponseByLanguageV1(code int, lang string) interface{} {
	return Response{code, constants.GetDefaultErrorMsg(code, lang), nil}
}

func BuildResponseDefinedMsgByLanguageV1(code int, lang string) interface{} {
	return Response{code, constants.GetTextByCode(code, lang), nil}
}

// BuildResponseByLanguageV2 build response v2
func BuildResponseByLanguageV2(code int, msg, lang string) interface{} {
	if len(msg) == 0 {
		msg = constants.GetDefaultErrorMsg(code, lang)
	}
	return Response{code, msg, nil}
}

func BuildResponseDefinedMsgByLanguageV2(code int, msg, lang string) interface{} {
	if len(msg) == 0 {
		msg = constants.GetTextByCode(code, lang)
	}
	return Response{code, msg, nil}
}

// BuildResponseByLanguageV3 build response v3
func BuildResponseByLanguageV3(code int, lang string, data interface{}) interface{} {
	return Response{code, constants.GetDefaultErrorMsg(code, lang), data}
}

func BuildResponseDefinedMsgByLanguageV3(code int, lang string, data interface{}) interface{} {
	return Response{code, constants.GetTextByCode(code, lang), data}
}

// BuildResponseByLanguageV4 build response v4
func BuildResponseByLanguageV4(code int, msg, lang string, data interface{}) interface{} {
	if len(msg) == 0 {
		msg = constants.GetDefaultErrorMsg(code, lang)
	}
	return Response{code, msg, data}
}

func BuildResponseDefinedMsgByLanguageV4(code int, msg, lang string, data interface{}) interface{} {
	if len(msg) == 0 {
		msg = constants.GetTextByCode(code, lang)
	}
	return Response{code, msg, data}
}

// BuildOutlineResponseByLanguage build outline response
func BuildOutlineResponseByLanguage(code int, msg, lang string, data interface{}, outline interface{}) interface{} {
	if len(msg) == 0 {
		msg = constants.GetTextByCode(code, lang)
	}
	return OutlineResponse{Response: Response{code, msg, data}, Outline: outline}
}
